<template>
	<view class="text-white">
		<view class="head">
			<view class=" u-flex u-p-l-30 u-p-t-30 u-p-b-30">
				<view class="u-m-r-10">
					<image :src="avatar?avatar:'../../../static/logo.png'"
						style="width: 100rpx;height: 100rpx;border-radius: 100rpx;"
						@click="goNav('/pages/my/userinfo')">
					</image>
					<!-- <view class="lovip" @click.stop="goNav('/my/renzheng/index')"
						v-if="status == 2 && yueSelect != '否'">
						<image src="../../../static/images/my/shim.png" style="width: 100%;height: 100%;"></image>
					</view> -->
				</view>
				<view class="flex align-center justify-between" style="width: 85%;position: relative;top: -10rpx;">
					<view class="u-flex-1 u-m-l-10 text-white">

						<view class="  text-bold flex align-center">
							<view class="text-30">{{userName}}</view>
							<image v-if="onLine" @tap="updateState"
								src="https://pw.xianmxkj.com/file/uploadPath/2023/03/23/53659d8d3996af8fe86d4ae6b1afe910.png"
								class="sxx_view"></image>
							<image v-if="!onLine" @tap="updateState"
								src="https://pw.xianmxkj.com/file/uploadPath/2023/03/23/fbd000b6f593f28b145de4f638a8b2e6.png"
								class="sxx_view"></image>
							<!-- <view v-if="status == 0 && yueSelect != '否'" class="label  "
								@click.stop="goNav('/my/renzheng/index')" style="">
								未认证
							</view>
							<view v-if="status == 1 && yueSelect != '否'" class="label"
								@click.stop="goNav('/my/renzheng/index')">
								审核中
							</view>
							<view v-if="status == 2 && yueSelect != '否'" class="label"
								@click.stop="goNav('/my/renzheng/index')">
								已认证
							</view>
							<view v-if="status == 3 && yueSelect != '否'" class="label"
								@click.stop="goNav('/my/renzheng/index')">
								已拒绝
							</view> -->
						</view>
						<view class="text-sm">ID：{{invitationCode}}</view>
					</view>
					<view class="flex align-center margin-right justify-end"
						@click="goNav('/my/gird/guanzhuDetail?userId='+userId+'&name=我的主页')" style="width: 30%;">
						<view class="margin-right-xs">主页中心</view>
						<image src="../../../static/images/index/right.png" style="width: 11upx;height: 20upx;"></image>
					</view>
				</view>
			</view>

			<view class="margin-lr bgs">
				<view class="flex justify-between align-center ">
					<view>
						<view class="">我的钱包</view>
						<view class="margin-top-xs" style="font-size:38upx;font-weight: bold;">{{money}}</view>
					</view>
					<view class="look" @click="goNav('/my/wallet/index?index=2')">
						<image
							src="https://pw.xianmxkj.com/file/uploadPath/2023/03/21/5d67f4f7149e6b9a8ace1453ed3b1dd9.png">
						</image>
					</view>

				</view>
			</view>

		</view>

		<view class="flex align-center justify-between margin-lr box" v-if="mylist.length!=0">
			<view @click="goNav(mylist[0].url)">
				<image :src="mylist[0].imageUrl"
					style="width: 333rpx;height:166rpx;"></image>
			</view>
			<view @click="goNav(mylist[1].url)">
				<image :src="mylist[1].imageUrl"
					style="width: 333rpx;height:166rpx;"></image>
			</view>
		</view>



		<!-- <view class="bgbox1 flex align-center justify-around">
			<view class="flex " @click="goNav('/my/takeOrder/index')">
				<view class="margin-right-sm">
					<view class="text-lg text-bold margin-bottom-xs">我的接单</view>
					<view style="color: #D4D4D4;font-size: 24upx;">查看接单更容易</view>
				</view>
				<image src="../../../static/images/my/jiadan.png" style="width: 89upx;height: 89upx;"></image>
			</view>
			<view style="width: 1rpx;height: 90upx;background: #E6E6E6;"></view>
			<view class="flex " @click="goNav('/my/publish/index')">
				<view class="margin-right-sm">
					<view class="text-lg text-bold margin-bottom-xs">我的服务</view>
					<view style="color: #D4D4D4;font-size: 24upx;">查看接单更容易</view>
				</view>
				<image src="../../../static/images/my/qiangdan.png" style="width: 89upx;height: 89upx;"></image>
			</view>
		</view> -->
		<view class="peibox">
			<view class="flex padding-lr padding-tb justify-between align-center"
				@click="goNav('/package/pages/play/order')">
				<view class="flex align-center">
					<image src="../../../static/images/my/qiangdanchi.png" style="width: 49rpx;height: 57rpx;"></image>
					<view class="flex-sub margin-left text-df">抢单池</view>
				</view>
				<image src="../../../static/images/index/right.png" style="width: 15rpx;height: 30rpx;"></image>
			</view>
			<view class="flex padding-lr padding-tb justify-between align-center"
				@click="goNav('/package/pages/play/robOrder')">
				<view class="flex align-center">
					<image src="../../../static/images/my/qiangdans.png" style="width: 55rpx;height: 57rpx;"></image>
					<view class="flex-sub margin-left text-df">我的抢单</view>
				</view>
				<image src="../../../static/images/index/right.png" style="width: 15rpx;height: 30rpx;"></image>
			</view>
			<view class="flex padding-lr padding-tb justify-between align-center" @click="goGonghui()">
				<view class="flex align-center">
					<image src="../../../static/images/my/gonghui1.png" style="width: 60rpx;height:57rpx;">
					</image>
					<view class="flex-sub margin-left text-df">我的公会</view>
				</view>
				<image src="../../../static/images/index/right.png" style="width: 15rpx;height: 30rpx;"></image>
			</view>
			<!-- <view class="flex padding-lr padding-tb justify-between align-center" @click="goGonghui()" v-if="!Huizhang">
				<view class="flex align-center">
					<image src="../../../static/images/my/gonghui1.png" style="width: 70rpx;height: 70rpx;">
					</image>
					<view class="flex-sub margin-left text-df">我的公会</view>
				</view>
				<image src="../../../static/images/index/right.png" style="width: 15rpx;height: 30rpx;"></image>
			</view> -->
		</view>
		
		<popup :show="popupshow" @closeT="popupshow = false" @sureT="sureT" :content="content"></popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				popupshow: false,
				content: '',
				
				userId: '',
				yueSelect: '否',
				invitationCode: '',
				money: '',
				userName: '匿名',
				avatar: '../../../static/logo.png',
				status: -1,
				safetyMoney: 0,
				isSafetyMoney: '',
				Huizhang: false,
				consortiaId: '',
				onLine: false,
				mylist:[]
			}
		},
		onLoad() {
			this.yueSelect = this.$queue.getData('yueSelect');
			this.invitationCode = this.$queue.getData('invitationCode');

			this.getMoney()
			this.getBannerList()
		},
		onShow() {
			this.userId = uni.getStorageSync('userId')

			if (this.userId) {
				this.isLogin = false
				this.getUserInfo()
				this.getMoney()
				this.getRenZheng()
			} else {
				this.isLogin = true
				this.userName = '匿名'
				this.safetyMoney = 0
				this.avatar = '../../static/logo.png'
			}
		},
		methods: {
			//获取技能  接单
			getBannerList() {
				this.$Request.get("/app/banner/selectBannerList", {
					classify:9
				}).then(res => {
					if (res.code == 0) {
						this.mylist = res.data
					}
				});
			},
			updateState() {
				this.$queue.showLoading('切换中...')
				let onLine = 1;
				if (this.onLine) {
					onLine = 2;
				}
				this.$Request.postT('/app/user/updateOnLine?onLine=' + onLine).then(res => {
					uni.hideLoading();
					if (res.code == 0) {
						this.$queue.showToast('切换成功！');
						this.getUserInfo()
					} else {
						this.$queue.showToast(res.msg);
					}
				});
			},
			//是否会长
			getUserTd() {
				let data = {
					consortiaId: this.consortiaId
				}
				this.$Request.get("/app/consortia/selectConsortiaById", data).then(res => {
					if (res.code == 0) {
						let userId = res.data.userId
						let myUserId = this.$queue.getData('userId');
						if (myUserId == userId) {
							console.log('我是会长：' + '少时诵诗书')
							this.Huizhang = true
						} else {
							console.log('我不是会长：' + '少时诵诗书')
							this.Huizhang = false
						}
						uni.setStorageSync("Huizhang", this.Huizhang)
					}
				});

			},
			//跳转公会
			goGonghui() {
				uni.navigateTo({
					url: '/package/pages/play/gonghui'
				})
			},
			getRenZheng() {
				this.$Request.get("/app/userCertification/queryInsert").then(res => {
					if (res.code == 0) {
						// 0审核中 1通过 2拒绝 
						if (res.data == null) {
							this.status = 0 //未实名
						} else if (res.data.status == 0) {
							this.status = 1 //审核中
						} else if (res.data.status == 1) {
							this.status = 2 //已实名
						} else if (res.data.status == 2) {
							this.status = 3 //已拒绝
						}
					}
				});
			},
			// 我的余额
			getMoney() {
				this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
					if (res.code == 0 && res.data) {
						console.log(res.data.money)
						this.money = res.data.money
					}
				});
			},
			getUserInfo() {
				this.$Request.get("/app/user/selectUserById").then(res => {
					if (res.code == 0) {
						this.consortiaId = res.data.consortiaId
						if (this.consortiaId) {
							this.getUserTd()
						}
						if (res.data.onLine && res.data.onLine == 1) {
							this.onLine = true;
						} else {
							this.onLine = false;
						}
						this.userName = res.data.userName
						// this.isSafetyMoney = res.data.isSafetyMoney
						this.invitationCode = res.data.invitationCode
						this.avatar = res.data.avatar ? res.data.avatar : '../../static/logo.png'

					}
				});
			},
			sureT(){
				uni.navigateTo({
					url: '/pages/public/login'
				})
				this.popupshow = false
			},
			goNav(e) {
				if (this.userId) {
					uni.navigateTo({
						url: e
					})
				} else {
					this.content = '您还未登录,请先登录'
					this.popupshow = true
					
				}
			},
		}
	}
</script>

<style lang="less">
	page {
		background: #111224;
	}

	.head {

		background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/20/c3e50814c6bb43cdeee6e046c93eae77.png');
		background-size: 100% 100%;
		/* #ifdef H5 */
		padding: 50rpx 0 20rpx 0;
		// height: 380rpx;
		/* #endif */
		
		/* #ifdef MP-WEIXIN */
		height: 320rpx;
		padding: 0rpx 0;
		/* #endif */
		
		/* #ifdef APP */
		// height: 320rpx;
		// padding-top: 40rpx
		padding: 40rpx 0 20rpx 0;
		/* #endif */
	}


	.bgs {
		color: #FFFFFF;
		background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/20/6eeeba5bc2623b57ca015560779e0e5a.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
		/* background: #272842; */
		border-radius: 12upx;
		/* padding:0 20rpx; */
		padding: 20rpx;
	}

	.bgbox1 {
		background: #272842;
		padding: 40upx 30upx;
		border-radius: 24upx;
		margin: 30upx;
	}

	.btn {
		color: #FFFFFF;
		background: #2087fe;
		border-radius: 10upx;
		font-size: 28upx;
		padding: 14upx 25upx;
	}

	.look {

		/* width: 150upx;
		height: 60upx;
		text-align: center;
		line-height: 60upx;
		color: #FFFFFF;
		background: #2087fe;
		border-radius: 10upx; */
		image {
			width: 130rpx;
			height: 64rpx;
		}
	}
	.box{
		/* #ifdef APP */
		margin-top: 40rpx;
		/* #endif */
	}

	.lovip {
		width: 43rpx;
		height: 35rpx;
		position: relative;
		top: -38rpx;
		left: 26rpx;
	}

	.peibox {
		margin: 20rpx 30rpx;
		background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/21/9cc004b3119efe39d9b66b942735de67.png');
		background-size: 100% 100%;
	}

	.label {
		display: inline-block;
		background-color: #6D709A;
		color: #FFFFFF;
		padding: 2upx 16upx;
		font-weight: 400;
		background-image: url('https://pw.xianmxkj.com/file/uploadPath/2023/03/21/ac89e556a1a91a0c82456a588791c1bf.png');
		background-size: 100% 100%;
		border-radius: 48rpx;
		margin-left: 30rpx;
		font-size: 26rpx;

	}

	.sxx_view {
		width: 98rpx;
		height: 40rpx;
		margin-left: 20rpx;
	}
</style>
